

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>prepare &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex/" />
    <link rel="search" title="Search" href="../../../search/" />
    <link rel="next" title="create" href="../create/" />
    <link rel="prev" title="加密" href="../encryption/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../">ceph-volume</a></li>
      <li class="breadcrumb-item active"><code class="docutils literal notranslate"><span class="pre">prepare</span></code></li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../../_sources/ceph-volume/lvm/prepare.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../">ceph-volume</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="../../#id2">迁移</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../../#id3">全新部署</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../../#osd">已有 OSD 怎么办</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../../intro/">Overview</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../intro/#replacing-ceph-disk">Replacing <code class="docutils literal notranslate"><span class="pre">ceph-disk</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../../intro/#gpt-partitions-are-simple">GPT partitions are simple?</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../intro/#modularity">Modularity</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../intro/#ceph-volume-lvm"><code class="docutils literal notranslate"><span class="pre">ceph-volume</span> <span class="pre">lvm</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../../intro/#lvm-performance-penalty">LVM performance penalty</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../systemd/">systemd</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../inventory/"><code class="docutils literal notranslate"><span class="pre">inventory</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../../drive-group/"><code class="docutils literal notranslate"><span class="pre">drive-group</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../"><code class="docutils literal notranslate"><span class="pre">lvm</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../activate/"><code class="docutils literal notranslate"><span class="pre">activate</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../batch/"><code class="docutils literal notranslate"><span class="pre">batch</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../batch/#ceph-volume-lvm-batch-report">报表</a></li>
<li class="toctree-l4"><a class="reference internal" href="../batch/#sizing">Sizing</a></li>
<li class="toctree-l4"><a class="reference internal" href="../batch/#idempotency-and-disk-replacements">Idempotency and disk replacements</a></li>
<li class="toctree-l4"><a class="reference internal" href="../encryption/">加密</a></li>
<li class="toctree-l4 current"><a class="current reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">prepare</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../create/"><code class="docutils literal notranslate"><span class="pre">create</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../scan/">scan</a></li>
<li class="toctree-l4"><a class="reference internal" href="../systemd/">systemd</a></li>
<li class="toctree-l4"><a class="reference internal" href="../list/"><code class="docutils literal notranslate"><span class="pre">list</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../zap/"><code class="docutils literal notranslate"><span class="pre">zap</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../migrate/"><code class="docutils literal notranslate"><span class="pre">migrate</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../newdb/"><code class="docutils literal notranslate"><span class="pre">new-db</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../newwal/"><code class="docutils literal notranslate"><span class="pre">new-wal</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../../simple/"><code class="docutils literal notranslate"><span class="pre">simple</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../../simple/activate/"><code class="docutils literal notranslate"><span class="pre">activate</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../../simple/scan/"><code class="docutils literal notranslate"><span class="pre">scan</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../../simple/systemd/">systemd</a></li>
<li class="toctree-l4"><a class="reference internal" href="../../zfs/"><code class="docutils literal notranslate"><span class="pre">zfs</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="../../zfs/inventory/"><code class="docutils literal notranslate"><span class="pre">inventory</span></code></a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="prepare">
<span id="ceph-volume-lvm-prepare"></span><h1><code class="docutils literal notranslate"><span class="pre">prepare</span></code><a class="headerlink" href="#prepare" title="Permalink to this heading"></a></h1>
<p>Before you run <code class="docutils literal notranslate"><span class="pre">ceph-volume</span> <span class="pre">lvm</span> <span class="pre">prepare</span></code>, we recommend that you provision a
logical volume. Then you can run <code class="docutils literal notranslate"><span class="pre">prepare</span></code> on that logical volume.</p>
<p><code class="docutils literal notranslate"><span class="pre">prepare</span></code> adds metadata to logical volumes but does not alter them in any
other way.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This is part of a two-step process to deploy an OSD. If you prefer
to deploy an OSD by using only one command, see <a class="reference internal" href="../create/#ceph-volume-lvm-create"><span class="std std-ref">create</span></a>.</p>
</div>
<p><code class="docutils literal notranslate"><span class="pre">prepare</span></code> uses <a class="reference internal" href="../../../glossary/#term-LVM-tags"><span class="xref std std-term">LVM tags</span></a> to assign several pieces of metadata to a
logical volume. Volumes tagged in this way are easier to identify and easier to
use with Ceph. <a class="reference internal" href="../../../glossary/#term-LVM-tags"><span class="xref std std-term">LVM tags</span></a> identify logical volumes by the role that they
play in the Ceph cluster (for example: BlueStore data or BlueStore WAL+DB).</p>
<p><a class="reference internal" href="../../../glossary/#term-BlueStore"><span class="xref std std-term">BlueStore</span></a> is the default backend. Ceph permits changing
the backend, which can be done by using the following flags and arguments:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#ceph-volume-lvm-prepare-bluestore"><span class="std std-ref">--bluestore</span></a></p></li>
</ul>
<section id="bluestore">
<span id="ceph-volume-lvm-prepare-bluestore"></span><h2><code class="docutils literal notranslate"><span class="pre">bluestore</span></code><a class="headerlink" href="#bluestore" title="Permalink to this heading"></a></h2>
<p><a class="reference internal" href="../../../glossary/#term-BlueStore"><span class="xref std std-term">Bluestore</span></a> is the default backend for new OSDs.  Bluestore
supports the following configurations:</p>
<ul class="simple">
<li><p>a block device, a block.wal device, and a block.db device</p></li>
<li><p>a block device and a block.wal device</p></li>
<li><p>a block device and a block.db device</p></li>
<li><p>a single block device</p></li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">bluestore</span></code> subcommand accepts physical block devices, partitions on physical
block devices, or logical volumes as arguments for the various device
parameters. If a physical block device is provided, a logical volume will be
created. If the provided volume group’s name begins with <cite>ceph</cite>, it will be
created if it does not yet exist and it will be clobbered and reused if it
already exists. This allows for a simpler approach to using LVM but at the
cost of flexibility: no option or configuration can be used to change how the
logical volume is created.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">block</span></code> is specified with the <code class="docutils literal notranslate"><span class="pre">--data</span></code> flag, and in its simplest use
case it looks like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "# ";
}
</style><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--bluestore<span class="w"> </span>--data<span class="w"> </span>vg/lv</span>
</pre></div></div><p>A raw device can be specified in the same way:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--bluestore<span class="w"> </span>--data<span class="w"> </span>/path/to/device</span>
</pre></div></div><p>For enabling <a class="reference internal" href="../encryption/#ceph-volume-lvm-encryption"><span class="std std-ref">encryption</span></a>, the <code class="docutils literal notranslate"><span class="pre">--dmcrypt</span></code> flag is required:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--bluestore<span class="w"> </span>--dmcrypt<span class="w"> </span>--data<span class="w"> </span>vg/lv</span>
</pre></div></div><p>Starting with Ceph Squid, you can opt for TPM2 token enrollment for the created LUKS2 devices with the <code class="docutils literal notranslate"><span class="pre">--with-tpm</span></code> flag:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--bluestore<span class="w"> </span>--dmcrypt<span class="w"> </span>--with-tpm<span class="w"> </span>--data<span class="w"> </span>vg/lv</span>
</pre></div></div><p>If a <code class="docutils literal notranslate"><span class="pre">block.db</span></code> device or a <code class="docutils literal notranslate"><span class="pre">block.wal</span></code> device is needed, it can be
specified with <code class="docutils literal notranslate"><span class="pre">--block.db</span></code> or <code class="docutils literal notranslate"><span class="pre">--block.wal</span></code>. These can be physical
devices, partitions, or logical volumes. <code class="docutils literal notranslate"><span class="pre">block.db</span></code> and <code class="docutils literal notranslate"><span class="pre">block.wal</span></code> are
optional for bluestore.</p>
<p>For both <code class="docutils literal notranslate"><span class="pre">block.db</span></code> and <code class="docutils literal notranslate"><span class="pre">block.wal</span></code>, partitions can be used as-is, and
therefore are not made into logical volumes.</p>
<p>While creating the OSD directory, the process uses a <code class="docutils literal notranslate"><span class="pre">tmpfs</span></code> mount to hold
the files needed for the OSD. These files are created by <code class="docutils literal notranslate"><span class="pre">ceph-osd</span> <span class="pre">--mkfs</span></code>
and are ephemeral.</p>
<p>A symlink is created for the <code class="docutils literal notranslate"><span class="pre">block</span></code> device, and is optional for <code class="docutils literal notranslate"><span class="pre">block.db</span></code>
and <code class="docutils literal notranslate"><span class="pre">block.wal</span></code>. For a cluster with a default name and an OSD ID of 0, the
directory looks like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># ls -l /var/lib/ceph/osd/ceph-0</span>
<span class="n">lrwxrwxrwx</span><span class="o">.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span> <span class="mi">93</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="n">block</span> <span class="o">-&gt;</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="n">be2b6fbd</span><span class="o">-</span><span class="n">bcf2</span><span class="o">-</span><span class="mi">4</span><span class="n">c51</span><span class="o">-</span><span class="n">b35d</span><span class="o">-</span><span class="n">a35a162a02f0</span><span class="o">/</span><span class="n">osd</span><span class="o">-</span><span class="n">block</span><span class="o">-</span><span class="mi">25</span><span class="n">cf0a05</span><span class="o">-</span><span class="mi">2</span><span class="n">bc6</span><span class="o">-</span><span class="mi">44</span><span class="n">ef</span><span class="o">-</span><span class="mi">9137</span><span class="o">-</span><span class="mi">79</span><span class="n">d65bd7ad62</span>
<span class="n">lrwxrwxrwx</span><span class="o">.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span> <span class="mi">93</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="n">block</span><span class="o">.</span><span class="n">db</span> <span class="o">-&gt;</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">sda1</span>
<span class="n">lrwxrwxrwx</span><span class="o">.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span> <span class="mi">93</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="n">block</span><span class="o">.</span><span class="n">wal</span> <span class="o">-&gt;</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">-</span><span class="n">wal</span><span class="o">-</span><span class="mi">0</span>
<span class="o">-</span><span class="n">rw</span><span class="o">-------.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span> <span class="mi">37</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="n">ceph_fsid</span>
<span class="o">-</span><span class="n">rw</span><span class="o">-------.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span> <span class="mi">37</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="n">fsid</span>
<span class="o">-</span><span class="n">rw</span><span class="o">-------.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span> <span class="mi">55</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="n">keyring</span>
<span class="o">-</span><span class="n">rw</span><span class="o">-------.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span>  <span class="mi">6</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="n">ready</span>
<span class="o">-</span><span class="n">rw</span><span class="o">-------.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span> <span class="mi">10</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="nb">type</span>
<span class="o">-</span><span class="n">rw</span><span class="o">-------.</span> <span class="mi">1</span> <span class="n">ceph</span> <span class="n">ceph</span>  <span class="mi">2</span> <span class="n">Oct</span> <span class="mi">20</span> <span class="mi">13</span><span class="p">:</span><span class="mi">05</span> <span class="n">whoami</span>
</pre></div>
</div>
<p>In the above case, a device was used for <code class="docutils literal notranslate"><span class="pre">block</span></code>, so <code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code> created
a volume group and a logical volume using the following conventions:</p>
<ul class="simple">
<li><p>volume group name: <code class="docutils literal notranslate"><span class="pre">ceph-{cluster</span> <span class="pre">fsid}</span></code> (or if the volume group already
exists: <code class="docutils literal notranslate"><span class="pre">ceph-{random</span> <span class="pre">uuid}</span></code>)</p></li>
<li><p>logical volume name: <code class="docutils literal notranslate"><span class="pre">osd-block-{osd_fsid}</span></code></p></li>
</ul>
</section>
<section id="filestore">
<span id="ceph-volume-lvm-prepare-filestore"></span><h2><code class="docutils literal notranslate"><span class="pre">filestore</span></code><a class="headerlink" href="#filestore" title="Permalink to this heading"></a></h2>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Filestore has been deprecated in the Reef release and is no longer supported.</p>
</div>
<p><code class="docutils literal notranslate"><span class="pre">Filestore&lt;filestore&gt;</span></code> is the OSD backend that prepares logical volumes for a
<cite>filestore</cite>-backed object-store OSD.</p>
<p><code class="docutils literal notranslate"><span class="pre">Filestore&lt;filestore&gt;</span></code> uses a logical volume to store OSD data and it uses
physical devices, partitions, or logical volumes to store the journal.  If a
physical device is used to create a filestore backend, a logical volume will be
created on that physical device. If the provided volume group’s name begins
with <cite>ceph</cite>, it will be created if it does not yet exist and it will be
clobbered and reused if it already exists. No special preparation is needed for
these volumes, but be sure to meet the minimum size requirements for OSD data and
for the journal.</p>
<p>Use the following command to create a basic filestore OSD:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--filestore<span class="w"> </span>--data<span class="w"> </span>&lt;data<span class="w"> </span>block<span class="w"> </span>device&gt;</span>
</pre></div></div><p>Use this command to deploy filestore with an external journal:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--filestore<span class="w"> </span>--data<span class="w"> </span>&lt;data<span class="w"> </span>block<span class="w"> </span>device&gt;<span class="w"> </span>--journal<span class="w"> </span>&lt;journal<span class="w"> </span>block<span class="w"> </span>device&gt;</span>
</pre></div></div><p>Use this command to enable <a class="reference internal" href="../encryption/#ceph-volume-lvm-encryption"><span class="std std-ref">encryption</span></a>, and note that the <code class="docutils literal notranslate"><span class="pre">--dmcrypt</span></code> flag is required:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--filestore<span class="w"> </span>--dmcrypt<span class="w"> </span>--data<span class="w"> </span>&lt;data<span class="w"> </span>block<span class="w"> </span>device&gt;<span class="w"> </span>--journal<span class="w"> </span>&lt;journal<span class="w"> </span>block<span class="w"> </span>device&gt;</span>
</pre></div></div><p>The data block device and the journal can each take one of three forms:</p>
<ul class="simple">
<li><p>a physical block device</p></li>
<li><p>a partition on a physical block device</p></li>
<li><p>a logical volume</p></li>
</ul>
<p>If you use a logical volume to deploy filestore, the value that you pass in the
command <em>must</em> be of the format <code class="docutils literal notranslate"><span class="pre">volume_group/logical_volume_name</span></code>. Since logical
volume names are not enforced for uniqueness, using this format is an important
safeguard against accidentally choosing the wrong volume (and clobbering its data).</p>
<p>If you use a partition to deploy filestore, the partition <em>must</em> contain a
<code class="docutils literal notranslate"><span class="pre">PARTUUID</span></code> that can be discovered by <code class="docutils literal notranslate"><span class="pre">blkid</span></code>. This ensures that the
partition can be identified correctly regardless of the device’s name (or path).</p>
<p>For example, to use a logical volume for OSD data and a partition
(<code class="docutils literal notranslate"><span class="pre">/dev/sdc1</span></code>) for the journal, run a command of this form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--filestore<span class="w"> </span>--data<span class="w"> </span>volume_group/logical_volume_name<span class="w"> </span>--journal<span class="w"> </span>/dev/sdc1</span>
</pre></div></div><p>Or, to use a bare device for data and a logical volume for the journal:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph-volume<span class="w"> </span>lvm<span class="w"> </span>prepare<span class="w"> </span>--filestore<span class="w"> </span>--data<span class="w"> </span>/dev/sdc<span class="w"> </span>--journal<span class="w"> </span>volume_group/journal_lv</span>
</pre></div></div><p>A generated UUID is used when asking the cluster for a new OSD. These two
pieces of information (the OSD ID and the OSD UUID) are necessary for
identifying a given OSD and will later be used throughout the
<a class="reference internal" href="../activate/#ceph-volume-lvm-activate"><span class="std std-ref">activation</span></a> process.</p>
<p>The OSD data directory is created using the following convention:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">/&lt;</span><span class="n">cluster</span> <span class="n">name</span><span class="o">&gt;-&lt;</span><span class="n">osd</span> <span class="nb">id</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>To link the journal volume to the mounted data volume, use this command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ln<span class="w"> </span>-s<span class="w"> </span>/path/to/journal<span class="w"> </span>/var/lib/ceph/osd/&lt;cluster_name&gt;-&lt;osd-id&gt;/journal</span>
</pre></div></div><p>To fetch the monmap by using the bootstrap key from the OSD, use this command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">/usr/bin/ceph<span class="w"> </span>--cluster<span class="w"> </span>ceph<span class="w"> </span>--name<span class="w"> </span>client.bootstrap-osd<span class="w"> </span>--keyring</span>
<span class="prompt1">/var/lib/ceph/bootstrap-osd/ceph.keyring<span class="w"> </span>mon<span class="w"> </span>getmap<span class="w"> </span>-o</span>
<span class="prompt1">/var/lib/ceph/osd/&lt;cluster<span class="w"> </span>name&gt;-&lt;osd<span class="w"> </span>id&gt;/activate.monmap</span>
</pre></div></div><p>To populate the OSD directory (which has already been mounted), use this <code class="docutils literal notranslate"><span class="pre">ceph-osd</span></code> command:
.. prompt:: bash #</p>
<blockquote>
<div><p>ceph-osd --cluster ceph --mkfs --mkkey -i &lt;osd id&gt; --monmap
/var/lib/ceph/osd/&lt;cluster name&gt;-&lt;osd id&gt;/activate.monmap --osd-data /var/lib/ceph/osd/&lt;cluster name&gt;-&lt;osd id&gt; --osd-journal
/var/lib/ceph/osd/&lt;cluster name&gt;-&lt;osd id&gt;/journal --osd-uuid &lt;osd uuid&gt;
--keyring /var/lib/ceph/osd/&lt;cluster name&gt;-&lt;osd id&gt;/keyring --setuser ceph
--setgroup ceph</p>
</div></blockquote>
<p>All of the information from the previous steps is used in the above command.</p>
</section>
<section id="ceph-volume-lvm-partitions">
<span id="id1"></span><h2>分区<a class="headerlink" href="#ceph-volume-lvm-partitions" title="Permalink to this heading"></a></h2>
<p><code class="docutils literal notranslate"><span class="pre">ceph-volume</span> <span class="pre">lvm</span></code> does not currently create partitions from a whole device.
If using device partitions the only requirement is that they contain the
<code class="docutils literal notranslate"><span class="pre">PARTUUID</span></code> and that it is discoverable by <code class="docutils literal notranslate"><span class="pre">blkid</span></code>. Both <code class="docutils literal notranslate"><span class="pre">fdisk</span></code> and
<code class="docutils literal notranslate"><span class="pre">parted</span></code> will create that automatically for a new partition.</p>
<p>For example, using a new, unformatted drive (<code class="docutils literal notranslate"><span class="pre">/dev/sdd</span></code> in this case) we can
use <code class="docutils literal notranslate"><span class="pre">parted</span></code> to create a new partition. First we list the device
information:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ parted --script /dev/sdd print
Model: VBOX HARDDISK (scsi)
Disk /dev/sdd: 11.5GB
Sector size (logical/physical): 512B/512B
Disk Flags:
</pre></div>
</div>
<p>This device is not even labeled yet, so we can use <code class="docutils literal notranslate"><span class="pre">parted</span></code> to create
a <code class="docutils literal notranslate"><span class="pre">gpt</span></code> label before we create a partition, and verify again with <code class="docutils literal notranslate"><span class="pre">parted</span>
<span class="pre">print</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ parted --script /dev/sdd mklabel gpt
$ parted --script /dev/sdd print
Model: VBOX HARDDISK (scsi)
Disk /dev/sdd: 11.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
</pre></div>
</div>
<p>Now lets create a single partition, and verify later if <code class="docutils literal notranslate"><span class="pre">blkid</span></code> can find
a <code class="docutils literal notranslate"><span class="pre">PARTUUID</span></code> that is needed by <code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ parted --script /dev/sdd mkpart primary 1 100%
$ blkid /dev/sdd1
/dev/sdd1: PARTLABEL=&quot;primary&quot; PARTUUID=&quot;16399d72-1e1f-467d-96ee-6fe371a7d0d4&quot;
</pre></div>
</div>
</section>
<section id="osd">
<span id="ceph-volume-lvm-existing-osds"></span><h2>对于已有 OSD<a class="headerlink" href="#osd" title="Permalink to this heading"></a></h2>
<p>For existing clusters that want to use this new system and have OSDs that are
already running there are a few things to take into account:</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>this process will forcefully format the data device, destroying
existing data, if any.</p>
</div>
<ul>
<li><p>OSD paths should follow this convention:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">/&lt;</span><span class="n">cluster</span> <span class="n">name</span><span class="o">&gt;-&lt;</span><span class="n">osd</span> <span class="nb">id</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
<li><p>Preferably, no other mechanisms to mount the volume should exist, and should
be removed (like fstab mount points)</p></li>
</ul>
<p>The one time process for an existing OSD, with an ID of 0 and using
a <code class="docutils literal notranslate"><span class="pre">&quot;ceph&quot;</span></code> cluster name would look like (the following command will <strong>destroy
any data</strong> in the OSD):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">prepare</span> <span class="o">--</span><span class="n">filestore</span> <span class="o">--</span><span class="n">osd</span><span class="o">-</span><span class="nb">id</span> <span class="mi">0</span> <span class="o">--</span><span class="n">osd</span><span class="o">-</span><span class="n">fsid</span> <span class="n">E3D291C1</span><span class="o">-</span><span class="n">E7BF</span><span class="o">-</span><span class="mi">4984</span><span class="o">-</span><span class="mi">9794</span><span class="o">-</span><span class="n">B60D9FA139CB</span>
</pre></div>
</div>
<p>The command line tool will not contact the monitor to generate an OSD ID and
will format the LVM device in addition to storing the metadata on it so that it
can be started later (for detailed metadata description see
<a class="reference internal" href="../../../dev/ceph-volume/lvm/#ceph-volume-lvm-tags"><span class="std std-ref">元数据</span></a>).</p>
</section>
<section id="crush">
<h2>CRUSH 设备类<a class="headerlink" href="#crush" title="Permalink to this heading"></a></h2>
<p>要设置 OSD 所属的 CRUSH 设备类，用 <code class="docutils literal notranslate"><span class="pre">--crush-device-class</span></code>
选项。对基于 bluestore 和 filestore 的 OSD 都适用：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">prepare</span> <span class="o">--</span><span class="n">bluestore</span> <span class="o">--</span><span class="n">data</span> <span class="n">vg</span><span class="o">/</span><span class="n">lv</span> <span class="o">--</span><span class="n">crush</span><span class="o">-</span><span class="n">device</span><span class="o">-</span><span class="k">class</span> <span class="nc">foo</span>
</pre></div>
</div>
</section>
<section id="multipath">
<span id="ceph-volume-lvm-multipath"></span><h2><code class="docutils literal notranslate"><span class="pre">multipath</span></code> 支持<a class="headerlink" href="#multipath" title="Permalink to this heading"></a></h2>
<p><code class="docutils literal notranslate"><span class="pre">multipath</span></code> devices are supported if <code class="docutils literal notranslate"><span class="pre">lvm</span></code> is configured properly.</p>
<p><strong>Leave it to LVM</strong></p>
<p>Most Linux distributions should ship their LVM2 package with
<code class="docutils literal notranslate"><span class="pre">multipath_component_detection</span> <span class="pre">=</span> <span class="pre">1</span></code> in the default configuration. With this
setting <code class="docutils literal notranslate"><span class="pre">LVM</span></code> ignores any device that is a multipath component and
<code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code> will accordingly not touch these devices.</p>
<p><strong>Using filters</strong></p>
<p>Should this setting be unavailable, a correct <code class="docutils literal notranslate"><span class="pre">filter</span></code> expression must be
provided in <code class="docutils literal notranslate"><span class="pre">lvm.conf</span></code>. <code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code> must not be able to use both the
multipath device and its multipath components.</p>
</section>
<section id="id2">
<h2>存入元数据<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>不管是什么类型的卷（日志或数据）或 OSD 对象存储器，下面的标签都会在准备过程中打上：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">cluster_fsid</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">encrypted</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">osd_fsid</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">osd_id</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">crush_device_class</span></code></p></li>
</ul>
<p>如果是 <a class="reference internal" href="../../../glossary/#term-BlueStore"><span class="xref std std-term">bluestore</span></a> 会加上这些标签：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">block_device</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">block_uuid</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">db_device</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">db_uuid</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">wal_device</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">wal_uuid</span></code></p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>完整的 LVM 标签惯例见 <a class="reference internal" href="../../../dev/ceph-volume/lvm/#ceph-volume-lvm-tag-api"><span class="std std-ref">Tag API</span></a> 。</p>
</div>
</section>
<section id="id3">
<h2>总结<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>To recap the <code class="docutils literal notranslate"><span class="pre">prepare</span></code> process for <a class="reference internal" href="../../../glossary/#term-BlueStore"><span class="xref std std-term">bluestore</span></a>:</p>
<ol class="arabic simple">
<li><p>Accepts raw physical devices, partitions on physical devices or logical volumes as arguments.</p></li>
<li><p>Creates logical volumes on any raw physical devices.</p></li>
<li><p>Generate a UUID for the OSD</p></li>
<li><p>Ask the monitor get an OSD ID reusing the generated UUID</p></li>
<li><p>OSD data directory is created on a tmpfs mount.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">block</span></code>, <code class="docutils literal notranslate"><span class="pre">block.wal</span></code>, and <code class="docutils literal notranslate"><span class="pre">block.db</span></code> are symlinked if defined.</p></li>
<li><p>monmap is fetched for activation</p></li>
<li><p>Data directory is populated by <code class="docutils literal notranslate"><span class="pre">ceph-osd</span></code></p></li>
<li><p>Logical Volumes are assigned all the Ceph metadata using lvm tags</p></li>
</ol>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../encryption/" class="btn btn-neutral float-left" title="加密" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../create/" class="btn btn-neutral float-right" title="create" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>